package com.xinke.module.system.mapper.user;

import java.util.*;

import com.xinke.component.common.pojo.PageResult;
import com.xinke.component.mybatis.mybatis.core.query.LambdaQueryWrapperExt;
import com.xinke.component.mybatis.mybatis.core.mapper.BaseMapperExt;
import com.xinke.module.system.model.entity.user.AdminUserDO;
import org.apache.ibatis.annotations.Mapper;
import com.xinke.module.system.model.vo.user.*;

/**
 * 用户信息 Mapper
 *
 * @author yzx
 */
@Mapper
public interface AdminUserMapper extends BaseMapperExt<AdminUserDO> {

    default PageResult<AdminUserDO> selectPage(AdminUserPageReqVO reqVO, Collection<Long> deptIds, Collection<Long> userIds) {
        return selectPage(reqVO, new LambdaQueryWrapperExt<AdminUserDO>()
                .likeIfPresent(AdminUserDO::getUserName, reqVO.getUserName())
                .likeIfPresent(AdminUserDO::getUserPhone, reqVO.getUserPhone())
                .eqIfPresent(AdminUserDO::getUserStatus, reqVO.getUserStatus())
                .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(AdminUserDO::getDeptId, deptIds)
                .inIfPresent(AdminUserDO::getUserId, userIds)
                .orderByDesc(AdminUserDO::getUserId));
    }
    default AdminUserDO selectByUsername(String username) {
        return selectOne(AdminUserDO::getUserName, username);
    }

    default AdminUserDO selectByEmail(String email) {
        return selectOne(AdminUserDO::getUserEmail, email);
    }

    default AdminUserDO selectByMobile(String mobile) {
        return selectOne(AdminUserDO::getUserPhone, mobile);
    }

}